package com.ken.blog.domain;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.persistence.Table;
import javax.transaction.Transactional;

@Table(name = "category")
@Qualifier("categoryRepository")
public interface CategoryRepository extends JpaRepository<Category, Long> {
    Category findOne(Long id);

    Category save(Category c);

    @Modifying
    @Transactional
    @Query("update Category c set c.title = ?1,c.description = ?2 where c.id = ?3")
    int update(String title, String description, Long id);
}